package edu.suda.xsap.service.impl;
import edu.suda.xsap.dto.MemCardDto;
import edu.suda.xsap.dto.convert.MemCardConvert;
import edu.suda.xsap.entity.MemCard;
import edu.suda.xsap.mapper.MemCardMapper;
import edu.suda.xsap.service.MemCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class MemCardServiceImpl implements MemCardService {
    @Autowired
    private MemCardConvert memCardConvert;

    @Autowired
    private MemCardMapper memCardMapper;

    @Override
    public void save(MemCard memCard) {
        memCardMapper.save(memCard);
    }

    @Override
    public List<MemCardDto> findAll() {
        List<MemCard> memCards = memCardMapper.findAll();
        return memCardConvert.toDtoList(memCards);
    }

    @Override
    public List<MemCardDto> findById(Integer id) {
        List<MemCard> memCards = memCardMapper.findById(id);
        return memCardConvert.toDtoList(memCards);
    }

    @Override
    public void update(MemCard memCard) {
        memCardMapper.update(memCard);
    }

    @Override
    public void deleteById(Integer id) {
        memCardMapper.deleteById(id);
    }
}

